import java.util.LinkedList;
import java.util.Stack;

public class Solution1 {
    //用栈打印逆序链表
    public void printList(LinkedList list) {
        Stack<Integer> stack = new Stack<>();
        int len = list.size();
        for (int i = 0; i < len; i++) {
            Integer val = (Integer)list.get(i);
            stack.push(val);
        }
        while(!stack.empty()) {
            System.out.println(stack.pop());
        }
    }
}
